﻿using System;
using DataGeneration.Domain.Logging;
using DataGeneration.Domain.Logic;
using DataGeneration.Domain.Helpers;

namespace DataGeneration
{
    class Program
    {
        static void Main(string[] args)
        {
            Logger.WriteMessage("Starting Data Generation ...");
            var exitText = "";

            ApplicationSettings.ConfigSystem();

            while (!exitText.Equals("n"))
            {
                try
                {
                    var orchestrationController = new PatternProcessor();
                    orchestrationController.GenerateDataLoadScriptFromXml();
                    orchestrationController.UpdateSequences();
                    Logger.WriteMessage("Completed Data Generation Successfuly!");
                }
                catch (Exception exception)
                {
                    Logger.WriteMessage(string.Format("An error occured with the following details:\n{0}.\nCorrect the error and run the application again.", exception.Message));
                }
                Logger.WriteMessage("To exit type N and hit Enter. To continue just hit Enter");
                exitText = Console.ReadLine() ?? "";
                exitText = exitText.Trim().ToLower();
            }
        }
    }
}
